//
//  MCCollVCellInfo.m
//  QuKeClient
//
//  Created by delicious on 2017/12/1.
//  Copyright © 2017年 delicious. All rights reserved.
//

#import "MCCollVCellInfo.h"
#import "BaseCollectionView.h"
#import "UIView+Base.h"

@implementation MCCollVCellInfo

+(MCCollVCellInfo *)configForCellId:(NSString *)cellId
                              Class:(Class)aClass
                               Line:(CGFloat)lineSpacing
                          Interitem:(CGFloat)interitemSpacing
                     CollectionView:(UICollectionView *)collectionView
                           SizeCell:(CGSize)sizeCell
                         InsetsCell:(UIEdgeInsets)insetsCell IsSection:(BOOL)isSection{

    MCCollVCellInfo *cellInfo = [collectionView.cellConfigDic valueForKey:cellId];
    if (!cellInfo) {
        cellInfo = [[MCCollVCellInfo alloc]init];
        cellInfo.cellId = cellId;
        cellInfo.aClass = aClass;
        cellInfo.lineSpacing  = lineSpacing;
        cellInfo.interitemSpacing = interitemSpacing;
        cellInfo.sizeCell = sizeCell;
        cellInfo.insetsCell = insetsCell;
        [collectionView.cellConfigDic setValue:cellInfo forKey:cellId];
    }
    if(isSection)
    {
        cellInfo.sizeCell = sizeCell;
    }
    return cellInfo;
}
@end



@implementation MCReusableViewInfo

+(MCReusableViewInfo *)configForViewId:(NSString *)viewId
                        CollectionView:(BaseCollectionView *)collectionView
                              SizeView:(CGSize)sizeView
{
    return [MCReusableViewInfo configForViewId:viewId CollectionView:collectionView SizeView:sizeView IsSize:NO];
}

+(MCReusableViewInfo *)configForViewId:(NSString *)viewId
                        CollectionView:(BaseCollectionView *)collectionView
                              SizeView:(CGSize)sizeView
                                IsSize:(BOOL)isSize
{
    MCReusableViewInfo *viewInfo = [collectionView.viewConfigDic valueForKey:viewId];
    if (!viewInfo) {
        viewInfo = [[MCReusableViewInfo alloc]init];
        viewInfo.viewId = viewId;
        viewInfo.sizeView = sizeView;
        [collectionView.viewConfigDic setValue:viewInfo forKey:viewId];
    }
    if(isSize)
    {
        viewInfo.sizeView = sizeView;
    }
    return viewInfo;
}
@end



